/** 号码前缀信息 */
import request from '@/utils/request'

/** 新增
 * @params {object} data
*/
export function postPrefixNumberInfo(data) {
  return request({
    method: 'POST',
    url: '/call-center/api/v1/prefixNumberInfo',
    data
  })
}
/** 修改
 * @params {object} data
 */
export function putPrefixNumberInfo(data) {
  return request({
    method: 'PUT',
    url: '/call-center/api/v1/prefixNumberInfo',
    data
  })
}
/** 查询所有
 */
export function getPrefixNumberInfo() {
  return request({
    method: 'GET',
    url: '/call-center/api/v1/prefixNumberInfo/'
  })
}
/** 根据id查询
 * @params {string} id
 */
export function getByIdPrefixNumberInfo(id) {
  return request({
    method: 'GET',
    url: `/call-center/api/v1/prefixNumberInfo/${id}`
  })
}
/** 删除
 * @params {string} id
 */
export function deletePrefixNumberInfo(id) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v1/prefixNumberInfo/${id}`
  })
}
/** 批量删除
 */
export function deleteBatch(ids) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v1/prefixNumberInfo/deleteBatch`,
    data: ids
  })
}
/** 根据skillNo查询
 * @params {string} id
 * @params {number} telecomOperator 运营商
 */
export function getQueryOneAvailable(id, telecomOperator) {
  const filtersRaw = []
  if (telecomOperator) {
    filtersRaw.push({ id: 'telecomOperator', property: 'telecomOperator', value: telecomOperator, operator: '=' })
  } else {
    filtersRaw.push({ id: 'telecomOperator', property: 'telecomOperator', value: `[5,6,7]`, operator: 'NOT IN' })
  }
  const data = new FormData()
  data.append('filtersRaw', JSON.stringify(filtersRaw))
  return request({
    method: 'POST',
    url: `/call-center/api/v1/prefixNumberInfo/queryOneAvailable/${id}`,
    data
  })
}
/** 修改前缀使用标记 */
export function putPrefixNumberInfoIsUsed(id, isUsed) {
  return request({
    method: 'PUT',
    url: `/call-center/api/v1/prefixNumberInfo/${id}/${isUsed}`
  })
}
// 导入
export function numberImport(data) {
  return request({
    url: '/call-center/api/v1/prefixNumberInfo/import',
    method: 'post',
    data,
    timeout: 10 * 60 * 1000
  })
}
